class TipoController < ApplicationController
  
  define_model_name 'Tipo'
  
  def index
    list
    render :action => 'list'
  end

  # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
  verify :method => :post, :only => [ :destroy, :create, :update ],
         :redirect_to => { :action => :list }

  def list
    @tipo_pages, @tipos = paginate :tipos, :per_page => 10
    list_title
  end

  def show
    @tipo = Tipo.find(params[:id])
    show_title @tipo.nome
  end

  def new
    @tipo = Tipo.new
    new_title
  end

  def create
    @tipo = Tipo.new(params[:tipo])
    if @tipo.save
      created_notice
      redirect_to :action => 'list'
    else
      render :action => 'new'
    end
  end

  def edit
    @tipo = Tipo.find(params[:id])
    edit_title @tipo.nome
  end

  def update
    @tipo = Tipo.find(params[:id])
    if @tipo.update_attributes(params[:tipo])
      updated_notice
      redirect_to :action => 'show', :id => @tipo
    else
      render :action => 'edit'
    end
  end

  def destroy
    Tipo.find(params[:id]).destroy
    redirect_to :action => 'list'
  end
end
